/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managers;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Date;

/**
 *
 * @author User
 */
public class PDFWriter {

    public PDFWriter() {
        createPDF();
    }
    
    public void createPDF() {
        Document document=new Document();
        File file=new File("d:/Documenti/Scuola/III anno/Programmazione per il web/Progetti/Progetto1/Materiale/WelcomeMedico/pdf/Pdf.pdf");
        try {
            PdfWriter.getInstance(document, new FileOutputStream(file));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        document.open();
        Date d=new Date(System.currentTimeMillis());
        Paragraph p0=new Paragraph(d.getDate()+"/"+d.getMonth()+"/"+(1900+d.getYear())+"\n\n");
        p0.setAlignment(Paragraph.ALIGN_RIGHT);
        Paragraph p1=new Paragraph("Egregio Signor/a " + ",");
        Paragraph p2=new Paragraph("La invitiamo a presentarsi per la vaccinazione in data "+d.toString()+". Di seguito riportiamo i precedenti richiami.");
        p2.setAlignment(Paragraph.ALIGN_JUSTIFIED);
        Paragraph p3=new Paragraph("Cordiali Saluti.\n\n");
        Paragraph p4=new Paragraph("Dr. ");
        p4.setAlignment(Paragraph.ALIGN_RIGHT);
        try {
            document.add(p0);
            document.add(p1);
            document.add(p2);
            document.add(p3);
            document.add(p4);
        } catch (DocumentException ex) {
            ex.printStackTrace();
        }
        document.close();
    }
}
